package com.google.gson.internal.bind;

import com.google.gson.a.a;
import com.google.gson.b.d;
import com.google.gson.j;
import com.google.gson.k;
import java.io.IOException;

public abstract class TypeAdapter {

    public interface Factory {
        TypeAdapter create(l lVar, a aVar);
    }

    public j a(Object obj) {
        try {
            d iVar = new i();
            iVar.b(true);
            a(iVar, obj);
            return iVar.a();
        } catch (Throwable e) {
            throw new k(e);
        }
    }

    public Object a(j jVar) {
        try {
            com.google.gson.b.a hVar = new h(jVar);
            hVar.a(true);
            return b(hVar);
        } catch (Throwable e) {
            throw new k(e);
        }
    }

    public abstract void a(d dVar, Object obj) throws IOException;

    public abstract Object b(com.google.gson.b.a aVar) throws IOException;
}
